//    Copyright (c) 2009 Elwyn Malethan
//
//    This file is part of SeemoreJ.
//
//    SeemoreJ is free software: you can redistribute it and/or modify
//    it under the terms of the GNU General Public License as published by
//    the Free Software Foundation, either version 3 of the License, or
//    (at your option) any later version.
//
//    SeemoreJ is distributed in the hope that it will be useful,
//    but WITHOUT ANY WARRANTY; without even the implied warranty of
//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//    GNU General Public License for more details.

//    You should have received a copy of the GNU General Public License
//    along with SeemoreJ.  If not, see <http://www.gnu.org/licenses/>.

package com.malethan.seemorej.rendering;

import com.malethan.seemorej.context.Context;

import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import java.io.IOException;

public class JspRendering implements Rendering {
    //----------------------------------------------------------------------- Static Properties and Constants
    //----------------------------------------------------------------------- Static Methods
    //----------------------------------------------------------------------- Instance Properties

    private String jspPath;

    //----------------------------------------------------------------------- Constructors

    public JspRendering(String jspPath) {
        this.jspPath = jspPath;
    }

    //----------------------------------------------------------------------- Getters and Setters

    public String getJspPath() {
        return jspPath;
    }

    //----------------------------------------------------------------------- Instance Methods

    public void render(ServletContext servletContext, Context seemoreContext) throws IOException, ServletException {
        servletContext.getRequestDispatcher(jspPath).forward(seemoreContext.getRequest(), seemoreContext.getResponse());
    }
}
